import { Button, Radio, Space, Table } from 'antd';
import { useState, useEffect } from 'react'
import _, { map } from 'lodash';
import LittleTitle from '../../../../../../../common/LittleTitle';
import DetailList from '../../../common/JudgeAnalysis/DetailList';
import useMap from '../../../hooks/useMap';
export default function CztzhfxResult(props) {
    const { result, onUpdate } = props;
    // console.log('result', result)
    const map = useMap();
    return <div style={{
        padding: "0 12px"
    }}>
        <LittleTitle>分析概要</LittleTitle>
        <div style={{
            margin: "8px 0 16px 0"
        }}>
            <div style={{
                // textAlign: "center"  
            }}>
                该区域共有承灾体
                <span style={{
                    fontWeight: "bold",
                    color: '#f50',
                    padding: "0 3px"
                }}>{_.sumBy(result.data, 'count')}</span>
                处
            </div>
        </div>

        <LittleTitle>结果详情</LittleTitle>
        <Space direction='vertical' style={{
            marginTop: 8,
            width: '100%'
        }}>
            <Table bordered size="small" dataSource={result?.data} columns={[{
                dataIndex: 'cztxl',
                title: '类型',
                width: 160,
                ellipsis: true
            }, {
                title: '数量',
                dataIndex: 'count',
                align: 'center'
            }, {
                width: 80,
                align: "center",
                render: (a, record) => {

                    return <Button type="link" size="small" onClick={() => {
                        map.dispatchEvent({
                            type: 'detail.show2',
                            title: record.cztxl,
                            component: <DetailList type="czt" cztxl={record.cztxl} wkt={result.wkt} />
                        })
                    }} >详情</Button>
                }
            }]} pagination={{
                pageSize: 10
            }} />
        </Space>
    </div>;
}